/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Model.Bookticketdetails;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author Sony
 */
public class BookticketdetailsHelper {
    Session session;
    public BookticketdetailsHelper(){
        session = HibernateUtil.getSessionFactory().getCurrentSession();
    }
    
    public List<Bookticketdetails> listAllBookticketdetails(){
        List<Bookticketdetails> lstBookticketdetails = null;
        try {
            org.hibernate.Transaction tx = this.session.beginTransaction();
            Query q = this.session.createQuery("from Bookticketdetails");
            lstBookticketdetails = (List<Bookticketdetails>)q.list();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return lstBookticketdetails;
    }
    
    public void updateBookticketdetails(Bookticketdetails b){
        try {
            org.hibernate.Transaction tx = this.session.beginTransaction();
            this.session.save(b);
            tx.commit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public void deleteBookticketdetails(Bookticketdetails b){
        try {
            org.hibernate.Transaction tx = this.session.beginTransaction();
            this.session.delete(b);
            tx.commit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
